package com.example.controller;

import cn.hutool.http.HttpUtil;
import com.example.mall.Product;
import com.example.util.MockData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * @ClassName ProductController
 * @Description TODO
 * @Author: XMK
 * @Date: 2020/4/3 14:38
 * @Version: 1.0
 */
@RestController
@RequestMapping("/product")
@Slf4j
public class ProductController {

    @GetMapping("/selectProductListByType/{productType}")
    public List<Product> selectProductListByType(@PathVariable("productType") String productType) {
        log.info("product getList服务，参数productType：{}", productType);
        return MockData.products();
    }

    @GetMapping("/getAccessToken/{sistsec}")
    public String getAccessToken(@PathVariable("sistsec") String sistsec) {

        HashMap<String, Object> param = new HashMap<>();
        param.put("sistid", "sistapp");
        param.put("sistsec", sistsec);

        String s = HttpUtil.get("http://10.204.169.190:8001/webocs/wx/token", param);

        return s;
    }
}
